package com.yqg.protection.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yqg.protection.common.Result;

import com.yqg.protection.service.ISdf300CurrentDataService;
import com.yqg.protection.entity.Sdf300CurrentData;

import org.springframework.web.bind.annotation.RestController;

/**
 * Sdf300CurrentDataController 前端控制器
 * @author zxf
 * @since 2025-08-08
 */
@RestController
@RequestMapping("/sdf300-current-data")
public class Sdf300CurrentDataController {

    @Resource
    private ISdf300CurrentDataService sdf300CurrentDataService;

    /**
    *  新增或者更新
    */
    @PostMapping("/edit")
    public Result save(@RequestBody Sdf300CurrentData sdf300CurrentData) {
        return Result.success(sdf300CurrentDataService.saveOrUpdate(sdf300CurrentData));
    }
    /**
    *  删除
    */
    @GetMapping("delete/{id}")
    public Result delete(@PathVariable Integer id) {
        Sdf300CurrentData sdf300CurrentData =sdf300CurrentDataService.getById(id);
        return Result.success(sdf300CurrentDataService.saveOrUpdate(sdf300CurrentData));
    }
    /**
    *  查询所有
    */
    @GetMapping("/all")
    public Result findAll() {
        QueryWrapper<Sdf300CurrentData> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", "0");
       List<Sdf300CurrentData> list=  sdf300CurrentDataService.list(queryWrapper);
        return Result.success(list);
    }
    /**
    *  根据id查询
    */
    @GetMapping("/{id}")
    public Result findOne(@PathVariable Integer id) {
        return Result.success(sdf300CurrentDataService.getById(id));
    }
    /**
    *  分页查询
    */
    @GetMapping("/page")
    public Result findPage(@RequestParam Integer pageNum,
                                @RequestParam Integer pageSize) {
        QueryWrapper<Sdf300CurrentData> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", "0");
        queryWrapper.orderByDesc("id");
        return Result.success(sdf300CurrentDataService.page(new Page<>(pageNum, pageSize), queryWrapper));
    }

}

